﻿'Params
'user (Required) : The last.fm username to fetch the charts list for.
'api_key (Required) : A Last.fm API key.

'Auth
' This service does not require authentication. 

Public Structure UserGetWeeklyChartListResponse
    Public charts()
    Public to_
    Public from_
End Structure

Public Class UserGetWeeklyChartList
	Inherits BaseRequest
    Dim user As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New()
        Me.user = user

	End Sub

	Public Sub sendRequest()
        InitializeMembers("user.getWeeklyChart")

        AddMember("user", user, True)
        AddMember("api_key", My.Settings.api_key, False)

        xmlresponse = sendPOSTResponse()
	End Sub

    Public Function getResponse() As UserGetWeeklyChartListResponse
        Dim response As New UserGetWeeklyChartListResponse
        Dim count As Integer
        Try
            count = xmlresponse.<lfm>.<weeklychartlist>.Count()
        Catch ex As Exception
            Return response
        End Try

        If (count > 0) Then
            ReDim response.charts(count - 1)
            For i As Integer = 0 To count - 1
                response.charts(i) = New Chart(xmlresponse.<lfm>.<weeklychartlist>(i))
            Next
        End If

        Return response
    End Function
End Class
